﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SmartSpace.UI.Silverlight.Dynamic.DynamicRef;

namespace SmartSpace.UI.Silverlight.Dynamic.Windows.Controls
{
    public partial class WfHistoryPart : UserControl
    {
        public WfHistoryPart()
        {
            InitializeComponent();
        }

        public WfHistoryPart(bool isStart)
            : this()
        {
            _ctlTxtYear.Text = string.Empty;
            _ctlTxtDate.Text = string.Empty;
            _ctlTxtSender.Text = string.Empty;
            _ctlTxtEvent.Text = string.Empty;

            if (isStart)
            {
                this._ctlLineUp.Visibility = System.Windows.Visibility.Collapsed;
            }
            else
            {
                this._ctlLineDown.Visibility = System.Windows.Visibility.Collapsed;
            }
        }

        public WfHistoryPart(WfDriveLog log, bool isFinished)
            : this()
        {
            if (isFinished)
            {
                _ctlTxtYear.Text = log.DriveDate.ToString("yyyy年");
                _ctlTxtDate.Text = log.DriveDate.ToString("MM月dd日");
                _ctlTxtSender.Text = log.From;
                _ctlTxtEvent.Text = log.Event;

                ToolTipService.SetToolTip(
                    this,
                    string.Format("{0}已在{1}{2}{3}", _ctlTxtSender.Text, _ctlTxtYear.Text, _ctlTxtDate.Text, _ctlTxtEvent.Text));
            }
            else
            {
                _ctlTxtYear.Text = string.Empty;
                _ctlTxtDate.Text = string.Empty;
                _ctlTxtSender.Text = log.To;
                _ctlTxtEvent.Text = log.Activity;
                ToolTipService.SetToolTip(
                    this,
                    string.Format("等待{0}{1}", _ctlTxtSender.Text, _ctlTxtEvent.Text));
            }
        }
    }
}
